const mongoose = require('mongoose')
const formatDate = require('../utils/dateFormat').formatDate

const Schema = mongoose.Schema
mongoose.set('useFindAndModify', false)
const date = formatDate(new Date(), true)

const AnnouncementSchema = new Schema({
  createdAt: {
    type: String,
    required: false,
    default: date
  },
  isDeleted: {
    type: Number,
    required: false,
    select: false,
    default: 0
  },
  title: {
    type: String,
    required: true,
    minlength: 1,
    maxlength: 50
  },
  // remark: {
  //   type: String,
  //   required: true,
  //   minlength: 1
  // },
  content: {
    type: String,
    required: true,
    minlength: 1
  },
  announcer: {
    type: String,
    required: true,
    minlength: 1
  }
})

module.exports = Announcement = mongoose.model('announcements', AnnouncementSchema)